﻿@using EasyCourse.Web.Controllers.Base;
@using EasyFramework.Core;
@using EasyCourse.BLL;
@using EasyCourse.Model;
@{
    Layout = null;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    ViewData["CourseId"] = pageInfo.CourseId;
    ViewData["MenuIndex"] = 10;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>作业列表</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @pageInfo.CourseName
                <br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicNav.cshtml",this.ViewData)
    <div class="container wrap mb15">
        <div class="row ">
            <div class="col-xs-9 publicLBox">
                <div class="lBox part">
                    <div class="lBox-th">
                        <h3>学生作业</h3>
                    </div>
                    <div class="lBox-tb2">
                        <ul class="zyList" id="JzyList"></ul>
                        <div class="row clearfix well d-page">
                            <div id="PagInfo" class="pull-left sum"></div>
                            <div class="clearfix pull-right">
                                <ul id="PageTool" class="pagination"></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-3">@Html.Partial("~/Views/Share/PublicRBox.cshtml", ViewData)</div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script type="text/javascript">
        var JzyList = $("#JzyList");
        var _JlistTop = $(".wrap").offset().top - $(".topNavPar").height();
        var _courseId = window.location.search.split("=")[1];
        var options = false;
        var _state = false;
        function getList(pageNo) {
            $.easyPost("@Url.Action("GetAssignList", "Assignment")", { "PageNO": pageNo, "PageSize": "10", "CourseId": _courseId},
               function (data) {
                   if (!data.result) { 
                       showTips.open(data.message);
                       return;
                   }
                    if (data.rows.length > 0) {
                        var _row = data.rows,
                            _rowL = _row.length,
                            _html = '';
                        // if (!options) {
                            options = {
                                totalPages: data.totalPage,
                                total: data.total,
                                currentPage: pageNo,
                                onPageClicked: function (event, originalEvent, type, page) { 
                                    getList(page);
                                }
                            }
                            initialPaginator(options, "PageTool", "PagInfo");
                        // }
                        for (var i = 0; i < _rowL; i++) {
                            var item = _row[i];
                            var _date = item.CreateTime.toString().replace(/\//g, "");             
                            var time = eval('new ' + _date);
                            _html += '<li>' +
                                        '<div class="zyList-th">' +
                                            '<span class="fl">' +
                                                '<a href="/Assignment/Detail?CourseId=@pageInfo.CourseId&CourseName=@pageInfo.CourseName&AssignmentId=' + item.Id + '" class="blue" target="_blank">' + item.Title + '</a>' +
                                            '</span>' +
                                            '<span class="fr lgray"> <i>发布人：' + item.Creator + '</i> <i>' + time.format('yyyy-MM-dd') + '</i>' +
                                            '</span>' +
                                        '</div>' +
                                        '<div class="zyList-tb">' +
                                            '<p class="pTxt">' + item.Remark + '<a href="/Assignment/Detail?CourseId=@pageInfo.CourseId&CourseName=@pageInfo.CourseName&AssignmentId=' + item.Id + '" target="_blank">[查看更多]</a>' +
                                            '</p>' +
                                        '</div>' +
                                    '</li>';
                        }
                        JzyList.html(_html);
                        if (_state) {
                            $('html,body').animate({ scrollTop: _JlistTop }, 0);
                        }
                        _state = true;
                       
                    } else {
                        var _html = '<li>暂无内容</li>';
                        JzyList.html(_html);
                    }
               }, "json");
        }
        if (!!window.location.hash) {
            var _hash = window.location.hash.substr(1);
            getList(_hash);
        } else {
            getList(1);
        }
        
    </script>
</body>
</html>